<?php

namespace api\modules\v1\controllers;
use api\common\controllers\CommonController;
use yii\web\ServerErrorHttpException;
use yii\web\HttpException;
use Yii;
class SimloginController extends CommonController
{
    public $modelClass = 'api\modules\v1\models\Simlogin';


    public function actions()
    {
        $actions = parent::actions();
        unset($actions['index'],$actions['update'], $actions['create'], $actions['delete'], $actions['view']); //卸载操作
        return $actions;
    }


    /*
     * 登录/注册账号
     * @return mixed
     */
    public function actionLr()
     {
         $model = new $this->modelClass();
         $model->scenario='lr_login';
         $model->attributes = Yii::$app->request->post();
         if ($data = $model->lr()) {
             return $data;
         }elseif (!$model->hasErrors()) {
             throw new ServerErrorHttpException('由于不明原因未能创建对象.');
         }else{
             throw new HttpException(401,array_values($model->getFirstErrors())[0],0);
         }
     }




}
